﻿using System;
using DBEmr.DAL;
using DBUtility;//请先添加引用
using System.Data;
using System.Text;
using System.Data.OracleClient;

namespace DBEmr.Model
{
    /// <summary>
    /// 单例模式
    /// </summary>
    public class DocAdvice
    {
        private static DocAdvice instance;       
        private static object _lock=new object();
        private DbHelperOra sql_help;

        private DocAdvice()      
        {
            sql_help = new DbHelperOra();
            //if (DBUtility.Set.ConType == 0)
            //    sql_help.connectionString = PubConstant.GetConfig("DBEMR");
            //else
            //    DbHelperSQL.connectionString = PubConstant.GetConfig("DBHIS");

            SetModel("2");
        }

        public static DocAdvice GetInstance()       
        {               
            if(instance==null)               
            {                      
                lock(_lock)                      
                {                            
                    if(instance==null)                             
                    {
                        instance = new DocAdvice();                            
                    }                      
                }              
            }               
            return instance;      
        }



        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void SetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select *");
            strSql.Append(" from CONFIG_SQL ");
            strSql.Append(" where SQL_Kind=" + ID);
            DBEmr.Model.CONFIGSQL model = new DBEmr.Model.CONFIGSQL();

            DataSet ds = null;
            ds = sql_help.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                da_sql = ds.Tables[0].Rows[0]["sql_content"].ToString();
                da_status = ds.Tables[0].Rows[1]["sql_content"].ToString();
                da_category = ds.Tables[0].Rows[2]["sql_content"].ToString();
                da_doc_stop = ds.Tables[0].Rows[3]["sql_content"].ToString();
                da_drug_group = ds.Tables[0].Rows[4]["sql_content"].ToString();
                da_excute_date = ds.Tables[0].Rows[5]["sql_content"].ToString();
                da_group_flag = ds.Tables[0].Rows[6]["sql_content"].ToString();
                da_use = ds.Tables[0].Rows[7]["sql_content"].ToString();
                da_frequency = ds.Tables[0].Rows[8]["sql_content"].ToString();
                da_remarks = ds.Tables[0].Rows[9]["sql_content"].ToString();
            }
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>

        /*
        */
        //变量
        /*
        H16 医嘱状态取消 0.未执行 1.执行中 2.停止执行 3.执行完成
        H45 医嘱类别: 1.术后医嘱;2. 产后医嘱;3. case "0"://普通
        H17 停止医嘱医师
        H11 药品分组编号-Ⅰ 组 Ⅱ 组Ⅲ 组 Ⅳ 组
        SD0 开始执行时间
        H33 分组标志
        H22 用法
        H23 频率
        H12 备注*/
        private string da_sql;

        public string Da_sql
        {
            get { return da_sql; }
            set { da_sql = value; }
        }
        //医嘱状态取消 0.未执行 1.执行中 2.停止执行 3.执行完成
        
        private string da_status;

        public string Da_status
        {
            get { return da_status; }
            set { da_status = value; }
        }
        //医嘱类别: 1.术后医嘱;2. 产后医嘱;3. case "0"://普通
        private string da_category;

        public string Da_category
        {
            get { return da_category; }
            set { da_category = value; }
        }
        //停止医嘱医师
        private string da_doc_stop;

        public string Da_doc_stop
        {
            get { return da_doc_stop; }
            set { da_doc_stop = value; }
        }
        //药品分组编号-Ⅰ 组 Ⅱ 组Ⅲ 组 Ⅳ 组
        private string da_drug_group;

        public string Da_drug_group
        {
            get { return da_drug_group; }
            set { da_drug_group = value; }
        }
        //开始执行时间
        private string da_excute_date;

        public string Da_excute_date
        {
            get { return da_excute_date; }
            set { da_excute_date = value; }
        }
        //分组标志
        private string da_group_flag;

        public string Da_group_flag
        {
            get { return da_group_flag; }
            set { da_group_flag = value; }
        }
        //用法
        private string da_use;

        public string Da_use
        {
            get { return da_use; }
            set { da_use = value; }
        }
        //频率
        private string da_frequency;

        public string Da_frequency
        {
            get { return da_frequency; }
            set { da_frequency = value; }
        }
        //备注
        private string da_remarks;

        public string Da_remarks
        {
            get { return da_remarks; }
            set { da_remarks = value; }
        }
    }
}

